package cn.ffcs.unm.testClient.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import cn.ffcs.unm.testClient.dao.IdCardInformationDao;
import cn.ffcs.uom.common.dao.BaseDaoImpl;

@Repository("idCardInformationDao")
public class IdCardInformationDaoImpl extends BaseDaoImpl implements
		IdCardInformationDao {

	@Override
	public IdCardInformationDao getCertIdVarInfo(String identity, String name) {
		List<Object> params = new ArrayList<Object>();
		String sql = "SELECT *  FROM TB_PTY_CERTIF_ID_VAR_INFO WHERE "
				+ " IDENTITY = ? AND NAME = ?";
		params.add(identity);
		params.add(name);
		List<IdCardInformationDao> idCardInformationList = jdbcFindList(sql,
				params, IdCardInformationDao.class);

		if (null != idCardInformationList && idCardInformationList.size() > 0) {
			return idCardInformationList.get(0);
		}
		return null;
	}

	@Override
	public boolean SaveIdCardInformation(String identity, String name) {
		if(null != identity && null != name){
			StringBuilder sb = new StringBuilder();
			sb.append("INSERT INTO TB_PTY_CERTIF_ID_VAR_INFO(IDENTITY, NAME) VALUES(?, ?)");
			this.getJdbcTemplate().update(sb.toString(), new Object[]{
				identity,
				name
			});
			return true;
		}
		return false;
	}

}
